package com.zcxy360.sandtable.controller;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zcxy360.sandtable.domain.TeamDrawingHistory;
import com.zcxy360.sandtable.service.TeamDrawingHistoryService;

/**
 * 小组图纸历史接口
 * @author 盛亚辉
 *
 */
@RequestMapping("course/team/teamDrawingHistory")
@RestController
public class TeamDrawingHistoryController {

	@Autowired
	private TeamDrawingHistoryService teamDrawingHistoryService;
	
	/**
	 * 获取小组图纸历史
	 * @param teamId 小组id
	 * @param drawingTypeId 图纸类型id
	 * @return 小组图纸历史对象
	 */
	@RequiresRoles("student")
	@GetMapping({"getLastHistory"})
	public Object getLastHistory(@RequestParam("teamId") Integer teamId,@RequestParam("drawingTypeId") Integer drawingTypeId) {
		return teamDrawingHistoryService.getLastHistory(teamId,drawingTypeId);
	}
	
	/**
	 * 获取小组图纸历史集合
	 * @param teamId 小组id
	 * @param drawingTypeId 图纸类型id
	 * @param pageNum 页码
	 * @param pageSize 页数
	 * @param navigatePages 导航数
	 * @return 小组图纸历史对象集合
	 */
	@RequiresRoles("student")
	@GetMapping
	public Object list(@RequestParam("teamId") Integer teamId,@RequestParam("drawingTypeId") Integer drawingTypeId,
			@RequestParam(defaultValue = "1") Integer pageNum,
			@RequestParam(defaultValue = "5") Integer pageSize,
			@RequestParam(defaultValue = "5") Integer navigatePages) {
		return teamDrawingHistoryService.list(teamId,drawingTypeId,pageNum,pageSize,navigatePages);
	}
	
	/**
	 * 新增小组图纸历史
	 * @param teamDrawingHistory 小组图纸历史字段
	 * @return 布尔值
	 */
	@RequiresRoles("student")
	@PostMapping
	public Object post(TeamDrawingHistory teamDrawingHistory) {
		return teamDrawingHistoryService.post(teamDrawingHistory);
	}
}
